/**
 * 
 */
package commons.base.http.client;

import java.io.IOException;

/**
 * @author yuan<cihang.yuan@happyelements.com>
 * @since 1.7
 */
public class HttpManager {
	
	private static ThreadPoolHttpClient threadPoolHttpClient;
	
	static{
		threadPoolHttpClient = new ThreadPoolHttpClient();
	}
	
	public static RequestBuilder newAsyncPost(String uri){
		return new RequestBuilder().setUri(uri).usePostMethod().setThreadPoolHttpClient(threadPoolHttpClient);
	}
	
	public static RequestBuilder newAsyncGet(String uri){
		return new RequestBuilder().setUri(uri).useGetMethod().setThreadPoolHttpClient(threadPoolHttpClient);
	}
	
	public static RequestBuilder newPost(String uri){
		return new RequestBuilder().setUri(uri).usePostMethod();
	}
	
	public static RequestBuilder newGet(String uri){
		return new RequestBuilder().setUri(uri).useGetMethod();
	}
	
	public static void shutdown(){
		if(threadPoolHttpClient != null){
			try {
				threadPoolHttpClient.shutdown();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}
	
}
